import store from '@/store'

/**
 * @param {Array} value
 * @returns {Boolean}
 * @example see @/views/auth/directive.vue
 */
export default function checkFlowTabPermission(value) {
  if (value && value instanceof Array && value.length > 0) {
    const flowTabPermission = store.getters && store.getters.flowTabPermission
    const permission= value
    const hasPermission = flowTabPermission.some(role => {
      return permission.includes(role)
    })

    if (!hasPermission) {
      return false
    }
    return true
  } else {
    console.error(`need TabPermission! Like checkFlowTabPermission(['ADMIN'])`)
    return false
  }
}
